package aoj.no_1100.no_1107;

import java.awt.Canvas;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class MainFrame extends Frame{
	private static final long serialVersionUID = 1L;
	private Canvas canvas = new Canvas() {
		private static final long serialVersionUID = 1L;
		public void paint(Graphics g) {
			//draw rectangle
			g.drawRect(0, 0, 600, 600);
		}
	};
	
	public MainFrame() {
		add(canvas);
				
		setSize(700, 700);
		setVisible(true);
		
		//enable to close window
		addWindowListener(new WindowAdapter() {
	        public void windowClosing(WindowEvent e)  {
	            System.exit(0);
	        }
		});	
		
	}
	
	public void draw(Point p1, Point p2) {
		Graphics g = canvas.getGraphics();
		g.drawLine(p1.x+10, p1.y+10, p2.x+10, p2.y+10);
	}
}
